
/*含对称轴的折线方程
* x自变量，axle对称轴，k对称轴左端直线斜率，b折点函数值
*/
double sym_line(double x , double axle , double k , double m)
{
	if(x<=axle) return k*(x-axle)+m;
	else return (0-k)*(x-axle)+m;
}
/*二维三角波方程
* x,y自变量，Tx,Ty两个分量周期，max,min上下限
* 以最小值点为原点
*/
double triangle_2(double x , double y , double Tx , double Ty , double min , double max)
{
	double kx = (max-min)/(Tx/2);
	double ky = (max-min)/(Ty/2);
	return sym_line((x/Tx-(int)(x/Tx))*Tx , Tx/2,kx,max)*sym_line((y/Ty-(int)(y/Ty))*Ty , Ty/2,ky,max);
}